import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from "@/views/Layout/Layout.vue";
import Home from "@/views/Home/Home.vue";
import Admin from "@/views/User/Admin.vue";

//异步
const Items = () => import('@/views/Items/Items.vue')
const Orders = () => import('@/views/Orders/Orders.vue')
const Message = () => import('@/views/Message/Message.vue')
const Knowledge = () => import('@/views/Knowledge/Knowledge.vue')
const User = () => import('@/views/User/User.vue')
Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        redirect: '/hlogin',
        component: Layout,
        children: [{
            path: '/home',
            name: 'Home',
            component: Home
        }, {
            path: '/item',
            name: 'Items',
            component: Items
        }, {
            path: '/orders',
            name: 'Orders',
            component: Orders,
            children: [
                {
                    path: 'processing', // 订单处理页面
                    name: 'OrderProcessing',
                    component: () =>
                        import ('@/views/Orders/OrdersProcessing.vue')
                },
                {
                    path: 'history', // 订单记录页面
                    name: 'OrderHistory',
                    component: () =>
                        import ('@/views/Orders/OrdersHistory.vue')
                },
                // 可以添加更多子路由
            ]
        }, {
            path: '/message',
            name: 'Message',
            component: Message
        }, {
            path: '/knowledge',
            name: 'Knowledge',
            component: Knowledge
        }, {
            path: '/user',
            name: 'User',
            component: User
        },
            {
            path: '/admin',
            name: 'Admin',
            component: Admin
        },]
    },
    {
        path: '/hlogin',
        name: 'hLogin',
        component: ()=>import('../views/Login/Login.vue')
    },
    {
        path: '/login',
        name: 'Login',
        component: ()=>import('../views/front/login.vue')
    },

    {
        path: '/front',
        name: 'Front',
        redirect: '/front/home',
        component: () => import('../views/front/Front.vue'),
        children: [
            {
                path: '/front/home',
                name: 'fHome',
                component: () => import('../views/front/Home.vue'),
                children: [{
                    path: '/front/banner',
                    name: 'banner',
                    component: () => import('../views/front/components/banner.vue')
                }, {
                    path: '/front/recommend',
                    name: 'recommend',
                    component: () => import('../views/front/components/recommend.vue')
                }, {
                    path: '/front/all',
                    name: 'all',
                    component: () => import('../views/front/components/all.vue')
                }, {
                    path: '/front/img',
                    name: 'img',
                    component: () => import('../views/front/components/imgDetail.vue')
                },
                  ]
            },
            {
                path: '/front/itemDetail/:id',
                name: 'ItemDetail',
                component: () => import('../views/front/components/itemDetail.vue'),
            },
            {
                path: '/front/orders',
                name: 'orders',
                component: () => import('../views/front/orders.vue')
            },
            {
                path: '/front/shop',
                name: 'shop',
                component: () => import('../views/front/shop.vue'),

            },
            {
                path: '/front/knowledge',
                name: 'knowledge',
                component: () => import('../views/front/knowledge.vue')
            },
            {
                path: '/front/cart',
                name: 'cart',
                component: () => import('../views/front/cart.vue')
            },
            {
                path: '/front/contract',
                name: 'contract',
                component: () => import('../views/front/contract.vue')
            },
            {
                path: '/front/uLogin',
                name: 'uLogin',
                component: () => import('../views/front/login.vue')
            },
            {
                path: '/front/register',
                name: 'Register',
                component: () => import('../views/front/Register.vue')
            },

        ]
    }
]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router
